<?php
include_once "objs/User.php";
include_once "objs/MenuPojo.php";
include_once "objs/MenusPojo.php";
include_once "objs/Instances.php";
include_once "models/MenuDetailDao.php";
include_once "models/Util.php";
include_once "models/MySqlDataAccessHelper.php";

$user = Util::getSessionParam('user');

MySqlDataAccessHelper::open();
//$a = "Nhà đá";
//echo $b;
$menuItems = MenuDetailDao::getAllMenus();
MySqlDataAccessHelper::close();
?>
<div id="zt-headerwrap">
    <div id="zt-header">
        <div id="zt-header-tr">
            <div id="zt-header-tl">
                <a id="zt-logo" class="png" href="<?php echo Instances::$URL ?>"
                   title="Dịch vụ visa Mỹ Úc"><img
                        src="imgs/blank.gif" alt="Dịch vụ visa Mỹ Úc"></a>
                <div id="zt-header-right">
                    <div id="zt-header-right-pad">

                        <div id="zt-topnav">

                            <ul class="menu">
                                <?php include 'menu2.php'; ?>
                            </ul>
                        </div>
                        <!-- begin login form-->
                        <div id="zt-loginform">
                            <?php if($user == NULL) { ?>
                            <form action=".?act=login" method="post" id="form-login">
                                <fieldset class="input">
                                    <p id="form-login-inner">
                                        <input id="modlgn_username" name="username"
                                               class="inputbox png" alt="username" size="20"
                                               value="Email"
                                               onblur="if (this.value == '')
                                                           this.value = this.defaultValue"
                                               onfocus="if (this.value == this.defaultValue)
                                                           this.value = ''"
                                               type="text"> <input id="modlgn_passwd"
                                               name="passwd" class="inputbox png" size="20"
                                               alt="password" value="......."
                                               onblur="if (this.value == '')
                                                           this.value = this.defaultValue"
                                               onfocus="if (this.value == this.defaultValue)
                                                           this.value = ''"
                                               type="password"> <input name="Submit"
                                               class="button png" value="Đăng nhập" type="submit">
                                    </p>

                                    <input name="option" value="com_users" type="hidden">
                                    <input name="task" value="user.login" type="hidden">
                                    <input name="return" value="aW5kZXgucGhwP0l0ZW1pZD00MzU="
                                           type="hidden"> <input
                                           name="f930754f08b2b8a73d1284ea2f7adedf" value="1"
                                           type="hidden">
                                </fieldset>
                                <ul>
                                    <li><a
                                            href="#"> Quên
                                            mật khẩu?</a></li>

                                    <li>No account yet <a
                                            href="dangki.php">
                                            Tạo tài khoản</a>
                                    </li>
                                </ul>
                            </form>
                            <?php }else{?>
                            <div id="welcomeuser" style="margin-top: 10px;">
                                Xin chào <font style="color: #e99d0b;"><?php echo $user->getName(); ?></font>. <a href=".?act=logout" style="color: #5F5F5F;">Thoát</a>
                                <?php if($user->isAdmin()){ echo '<br/> <a href="admin/index.html">Administrators</a>';
                             } ?>
                            </div>
                            <?php } ?>
                        </div>
                        <!-- end login form -->
                    </div>
                </div>

                <!-- Begin Menu -->
                <div id="zt-mainmenu" class="png">

                    <div id="zt-mainmenu-br" class="zt-mainmenu-right ">
                        <div id="zt-mainmenu-bl" class="zt-mainmenu-left">
                            <div class="menusys_mega">
                                <ul id="menusys_mega" class="level0">
                                    <!-- current menu item -->
                                    <li class="first-item  active">
                                        <a href="index.php" class="item active"	id="menusys435" title="Home">
                                            <span class="no-image"><span class="menu-title">Home</span></span>
                                        </a>
                                    </li>
                                    <!-- end current menu item -->
                                    <?php foreach($menuItems as $item){
                                        $menu = $item->getMenu();
                                        $subMenus1 = $item->getSubMenus();
                                    ?>
                                    <li id="menu-<?php echo $menu->getId();?>" class="hasChild item"><a id="menusys<?php echo $menu->getId();?>" href="<?php if(count($subMenus1)<=0){ echo "danhmuc.php?id=".$menu->getId()."00";}else{ echo "#";} ?>" title="<?php echo $menu->getName();?>" onmouseover="onMouseOverMenuItem('menu-<?php echo $menu->getId();?>_menusub_sub0')"><span class="no-image"><span class="menu-title"><?php echo $menu->getName();?></span></span></a>
                                        <?php 
                                        if(count($subMenus1)>0){
                                        ?>
                                        <div style="opacity: 0; margin: 0px;" id="menu-<?php echo $menu->getId();?>_menusub_sub0" class="menusub_mega">
                                            <div class="submenu-wrap" >
                                                <div class="subarrowtop"></div>
                                                <div class="subwrapcenter" style="width: 200px;display: block">
                                                    <div class="megacol column1" >
                                                        <ul class="mega-ul ul" >
                                                            <!-- begin sub-level0 menu item-->
                                                            <?php 
                                                                
                                                                foreach($subMenus1 as $subMenusItem1){
                                                                    $sub1Mn = $subMenusItem1->getMenu();
                                                                    $count = 2;
                                                                    $sub2Menus = $subMenusItem1->getSubMenus();
                                                            ?>
                                                            <li id="menu-<?php echo $menu->getId();echo $sub1Mn->getId();?>" class="mega-li li first-item<?php if(count($sub2Menus)>0) echo " hasChild" ?>"><a href="<?php if(count($sub2Menus)<=0){ echo "danhmuc.php?id=".$menu->getId().$sub1Mn->getId()."0";}else{ echo "#";} ?>" class=" item" id="menusys<?php echo $menu->getId();echo $sub1Mn->getId();?>" title="<?php echo $sub1Mn->getName(); ?>"><span class="no-image"><span class="menu-title"><?php echo $sub1Mn->getName(); ?></span></span></a>
                                                                <?php 
                                                                    if(count($sub2Menus)>0){
                                                                ?>
                                                                <div style="opacity: 0; margin: 0px;" id="menu-<?php echo $menu->getId();echo $sub1Mn->getId();?>_menusub_sub<?php echo $count; $count = $count + 1; ?>" class="menusub_mega">
                                                                    <div class="submenu-wrap" style="margin-top: -10000px;">
                                                                        <div class="subarrowtop"></div>
                                                                        <div class="subwrapcenter" style="width:">
                                                                            <div class="megacol column1">
                                                                                <ul class="mega-ul ul">
                                                                                    <!-- begin sub-level1 menu item-->
                                                                                    <?php 
                                                                                        
                                                                                        foreach($sub2Menus as $sub2Item){
                                                                                           $sub2Mn =  $sub2Item->getMenu();
                                                                                    ?>
                                                                                    <li class="mega-li li"><a href="danhmuc.php?id=<?php echo $menu->getId().$sub1Mn->getId().$sub2Mn->getId();?>" class=" item" id="menusys<?php echo $sub2Mn->getId()?>" title="<?php echo $sub2Mn->getName()?>"><span class="no-image"><span class="menu-title"><?php echo $sub2Mn->getName()?></span></span></a></li>
                                                                                    <?php } ?>
                                                                                    <!-- end sub-level0 menu item-->
                                                                                </ul>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                                    <?php } ?>
                                                            </li>
                                                                <?php } ?>
                                                            <script type="text/javascript">
												/*          */
												window
														.addEvent(
																"domready",
																function() {
																	var _smart = Array();
																	var megas = $(
																			document.body)
																			.getElements(
																					'div[class="menusub_mega"]');
																	megas
																			.each(function(
																					mega,
																					i) {
																				var id = mega
																						.getProperty(
																								"id")
																						.split(
																								"_");
																				if (id[2] != null) {
																					var smart = "_"
																							+ id[1]
																							+ "_"
																							+ id[2];
																					_smart
																							.include(smart);
																				}
																			});
																	_smart
																			.each(function(
																					item,
																					index) {
																				ZTMenu(
																						350,
																						0,
																						0,
																						item,
																						"megamenu_close",
																						true,
																						350,
																						Fx.Transitions.linear);
																			});
																}); /*     */
											</script>
                                                            <!-- end sub-level0 menu item-->

                                                        </ul>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    <?php } ?>
                                    </li>
                                     <?php } ?>

                                    <li class="last-item  item">
                                        <a href="lienhe.php" class=" item"
                                           id="menusys492" title="Liên hệ">
                                            <span class="no-image"><span class="menu-title">Liên hệ</span></span>
                                        </a>
                                    </li>
                                </ul>

                                
                            </div>

                            <div id="zt-search" class="">
                                <div class="png search">
                                    <form action="index.php" method="post">
                                        <input name="searchword" id="mod_search_searchword"
                                               maxlength="20" alt="Tìm" class="inputbox" size="20"
                                               value="Tìm kiếm..."
                                               onblur="if (this.value == '')
                                                           this.value = 'Tìm kiếm...';"
                                               onfocus="if (this.value == 'Tìm kiếm...')
                                                           this.value = '';"
                                               type="text"><input value="Tìm" class="button"
                                               onclick="this.form.searchword.focus();" type="submit">
                                        <input name="task" value="search" type="hidden"> <input
                                            name="option" value="com_search" type="hidden"> <input
                                            name="Itemid" value="435" type="hidden">
                                    </form>
                                </div>
                            </div>

                        </div>
                        <div class="clr"></div>
                    </div>
                </div>
                <!-- End Menu -->

                <div class="clr"></div>
            </div>
            <div class="clr"></div>
        </div>
    </div>
</div>
